# -*- coding: utf-8 -*-
# @Time    : 2019/9/19 14:20
# @Author  : Weymouth
# @Email   : 261229090@qq.com
# @File    : menu.py
# @Software: PyCharm
# ---------------------------------------------------

menu = {
    '北京': {
        '朝阳': {
            '国贸': {
                'abc': {}
            },
            '望京': {
                '360': {},
                '奔驰': {}
            }
        }
    }
}

back_flag = False
exit_flag = False

while not back_flag and not exit_flag:
    for key in menu:
        print(key)
    choice = input("1>>:").strip()
    if choice in menu:
        while not back_flag and not exit_flag:#让程序停留在第二层
            for key2 in menu[choice]:
                print(key2)
            choice2 = input("2>>:").strip()
            if choice2 == "b":
                back_flag = True
            if choice2 == "q":
                exit_flag = True
            if choice2 in menu[choice]:
                while not back_flag and not exit_flag:
                    for key3 in menu[choice][choice2]:
                        print(key3)
                    choice3 = input("3>>:").strip()
                    if choice3 == "b":
                        back_flag = True
                    if choice3 == "q":
                        exit_flag = True
                    if choice3 in menu[choice][choice2][choice3]:
                        while not back_flag and not exit_flag:
                            for key4 in menu[choice][choice2][choice3]:
                                print(key4)
                            choice4 = input("4>>:").strip()
                            print("last level")
                            if choice4 == "b":
                                back_flag = True
                            if choice4 == "q":
                                exit_flag = True
                        else:
                            back_flag = True
                else:
                    back_flag = True
        else:
            back_flag = True